package com.heima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.heima.pojo.Sku;
import com.heima.pojo.SkuClass;
import com.heima.pojo.dto.SkuClassPageQueryDTO;
import com.heima.pojo.vo.SkuVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SkuMapper extends BaseMapper<Sku> {

    Page<SkuVo> skuQuery(SkuClassPageQueryDTO sku);

    @Select("select * from tb_sku")
    List<Sku> queryAllSku();


    @Select("select * from tb_sku")
    List<SkuVo> queryAllSkuVo();

    @Select("select o.sku_id,o.sku_name,o.class_id,o.price,amount as realPrice,unit,ts.sku_image image,ts.is_discount discount\n" +
            "from tb_order o left join tb_sku ts on o.sku_id = ts.sku_id where business_id = #{businessId} limit 10")
    List<SkuVo> businessTop10(Integer businessId);
}
